package com.qingkai.onlineshop.presentation.dashboard

import androidx.compose.foundation.Image
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.util.fastForEach
import com.qingkai.onlineshop.R

/**
 *作者：created by 89270 on 2025/6/12 16:43
 *描述：
 */
@Preview(showBackground = true)
@Composable
fun DashboardBottomBar() {
    val menus = remember {
        listOf(
            Pair("Home", R.drawable.btn_1),
            Pair("Favorite", R.drawable.btn_2),
            Pair("Cart", R.drawable.btn_3),
            Pair("Profile", R.drawable.btn_4)
        )
    }

    var selected by remember { mutableIntStateOf(menus.first().second) }

    BottomAppBar {
        menus.fastForEach {
            NavigationBarItem(
                selected = it.second == selected,
                icon = { Image(painterResource(it.second), contentDescription = it.first) },
                label = {
                    Text(text = it.first)
                },
                onClick = { selected = it.second })
        }
    }
}